package com.lanxiao.cloud.modules.oauth.domain.model;

import cn.hutool.core.util.IdUtil;
import com.lanxiao.cloud.common.core.enums.StateEnum;
import com.lanxiao.cloud.modules.oauth.infrastructure.enums.LoginType;
import java.util.Date;

/**
 * @author ：qiaoliang
 * @date ：2021-10-20
 */
public class UserDetails {
  /** id **/
  private Long id;
  /** 昵称 **/
  private String name;
  /** 头像 **/
  private String portrait;
  /** 登录类型 **/
  private LoginType type;
  /** 登录账号 **/
  private String principal;
  /** 登录状态 **/
  private StateEnum state = StateEnum.NORMAL;
  /** 登录地区 **/
  private String region;
  /** 登录IP **/
  private String ip;
  /** 浏览器 **/
  private String browser;
  /** 操作系统 **/
  private String operatingSystem;

  /** 标识码 **/
  private final String uuId = IdUtil.simpleUUID();
  /** 登录时间 **/
  private final Date time = new Date();

  private UserDetails() {
  }

  public UserDetails(Long id, String name, String portrait,
      LoginType type, String principal, String region, String ip, String browser,
      String operatingSystem) {
    this.id = id;
    this.name = name;
    this.portrait = portrait;
    this.type = type;
    this.principal = principal;
    this.region = region;
    this.ip = ip;
    this.browser = browser;
    this.operatingSystem = operatingSystem;
  }

  /** 强制下线 **/
  public void forcedOffline() {
    this.state = StateEnum.ERROR;
  }

  public Long getId() {
    return id;
  }

  public String getName() {
    return name;
  }

  public String getPortrait() {
    return portrait;
  }

  public LoginType getType() {
    return type;
  }

  public String getPrincipal() {
    return principal;
  }

  public StateEnum getState() {
    return state;
  }

  public Date getTime() {
    return time;
  }

  public String getRegion() {
    return region;
  }

  public String getIp() {
    return ip;
  }

  public String getBrowser() {
    return browser;
  }

  public String getOperatingSystem() {
    return operatingSystem;
  }

  public String getUuId() {
    return uuId;
  }
}
